<template>
  <div class="hello">
    <div class="media-list">
      <div class="yui-flex-center item" v-for="(item, index) in news.news" :key="index">
        <div class="img">
          <img :src="item.imgUrl" alt="">
        </div>
        <div class="yui-flex-col list-main">
          <div class="title">{{item.title}}</div>
          <div class="yui-flex-center auth-area">
            <div>{{item.name}}</div>
            <div class="yui-flex-col time">{{item.createDate}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {getNewList} from '../api/news'
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
        news: []
    }
  },
    created () {
      this._newIndex();
    },
    methods: {
        _newIndex () {
            getNewList().then((res) => {
                this.news = res;
                console.log(res);
                console.log(res.news[2]);
            })
        }
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  /**
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  **/
  .media-list {
    padding: .15rem;
  }
  .media-list .item {
    width: 100%;
    padding: .15rem 0;
    border-bottom: 1px solid #dceedc;
  }
  .media-list .item .img {
    width: .7rem;
    height: .7rem;
    border-radius: 4px;
    overflow: hidden;
    margin-right: .1rem;
  }
  .media-list .list-main {
    overflow: hidden;
  }
  .media-list .item .title {
    font-size: .16rem;
    color: #333;
    margin-bottom: .12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
  }
  .media-list .item .auth-area {
    font-size: .12rem;
    line-height: .16rem;
    color: #868686;
  }
  .media-list .item .auth-area .time {
    text-align: right;
  }
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
img {
  max-width: 100%;
}
/*浮动盒子布局*/
.yui-flex {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
}
.yui-flex-center {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  /*垂直居中*/
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
  /*水平居中*/
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}
.yui-flex-center-top {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  /*水平居中*/
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}
.yui-flex-col {
  -webkit-box-flex: 1;
  -webkit-flex: 1;
  flex: 1;
}
</style>
